home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / pas / swag / oop.swg / 0028_PICKLIST in Turbo Vision.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  3KB  |  121 lines

  1. {
  2. From: BRIAN PAPE
  3. Subj: Picklist in TV
  4. }
  5.  
  6. {************************************************}
  7. {                                                }
  8. {   Turbo Vision 2.0 Demo                        }
  9. {   Copyright (c) 1992 by Borland International  }
  10. {                                                }
  11. {************************************************}
  12.  
  13. program PickList;
  14.  
  15. uses Objects, Views, Dialogs, App, Drivers,editors;
  16. const
  17.   cmPickClicked = 1001;
  18. type
  19.   PCityColl = ^TCityColl;
  20.   TCityColl = object(TStringCollection)
  21.     constructor Init;
  22.   end;
  23.  
  24.   PPickLine = ^TPickLine;
  25.   TPickLine = object(TMemo)
  26.     procedure HandleEvent(var Event: TEvent); virtual;
  27.   end;
  28.  
  29.   PPickWindow = ^TPickWindow;
  30.   TPickWindow = object(TDialog)
  31.     constructor Init;
  32.   end;
  33.  
  34.   TPickApp = object(TApplication)
  35.     PickWindow: PPickWindow;
  36.     constructor Init;
  37.   end;
  38.  
  39. VAR Lijst:PCityColl;
  40.     GControl: PView;
  41.     S  : String[30];
  42.  
  43.  
  44. constructor TCityColl.Init;
  45. begin
  46.   inherited Init(10, 10);
  47.   Insert(NewStr('Scotts Valley'));
  48.   Insert(NewStr('Sydney'));
  49.   Insert(NewStr('Copenhagen'));
  50.   Insert(NewStr('London'));
  51.   Insert(NewStr('Paris'));
  52.   Insert(NewStr('Munich'));
  53.   Insert(NewStr('Milan'));
  54.   Insert(NewStr('Tokyo'));
  55.   Insert(NewStr('Stockholm'));
  56. end;
  57.  
  58. procedure TPickLine.HandleEvent(var Event: TEvent);
  59. VAR
  60.   Count:Integer;
  61. begin
  62.   inherited HandleEvent(Event);
  63.   if (Event.What = evBroadcast) and (Event.command=cmListItemSelected) then
  64.     begin
  65.       S:=PListBox(Event.InfoPtr)^.GetText(PListBox(Event.InfoPtr)^.Focused,
  66.                                           high(s));
  67.       with PListBox(Event.InfoPtr)^ do
  68.       begin
  69.         s := s + #13;
  70.         InsertText(@s[1],length(s),false);
  71.       end;
  72.       DrawView;
  73.       ClearEvent(Event);
  74.     end;
  75. end;
  76.  
  77. constructor TPickWindow.Init;
  78. var
  79.   R: TRect;
  80.   Control: PView;
  81.   ScrollBar: PScrollBar;
  82. begin
  83.   R.Assign(0, 0, 40, 15);
  84.   inherited Init(R, 'Pick List Window');
  85.   Options := Options or ofCentered;
  86.   R.Assign(5, 2, 35, 4);
  87.   Control := New(Ppickline, Init(R,NIL,NIL,NIL, 130));
  88.   Control^.EventMask := Control^.EventMask or evBroadcast;
  89.   Insert(Control);
  90.   R.Assign(4, 1, 13, 2);
  91.   Insert(New(PLabel, Init(R, 'Picked:', Control)));
  92.   R.Assign(34, 5, 35, 11);
  93.   New(ScrollBar, Init(R));
  94.   Insert(ScrollBar);
  95.   R.Assign(5, 5, 34, 11);
  96.   gControl := New(PListBox, Init(R, 1, ScrollBar));
  97.   Insert(gControl);
  98.   PListBox(gControl)^.NewList(Lijst);
  99.   R.Assign(4, 4, 12, 5);
  100.   Insert(New(PLabel, Init(R, 'Items:', Control)));
  101.   R.Assign(15, 12, 25, 14);
  102.   Insert(New(PButton, Init(R, '~Q~uit', cmQuit, bfDefault)));
  103. end;
  104.  
  105. constructor TPickApp.Init;
  106. begin
  107.   inherited Init;
  108.   Lijst:=New(PCityColl,Init);
  109.   PickWindow := New(PPickWindow, Init);
  110.   InsertWindow(PickWindow);
  111. end;
  112.  
  113. var
  114.   PickApp: TPickApp;
  115. begin
  116.   PickApp.Init;
  117.   PickApp.Run;
  118.   PickApp.Done;
  119. end.
  120.  
  121.